$(function () {
   $("#datas").load(base + "/permission/stuInfo/list");

    $("#searchForm").submit(function (event) {
        event.preventDefault();

        $("#datas").load(base + "/permission/stuInfo/list?searchName=" + $("#searchName").val());
        return false;
    });

    $("#loginForm").submit(function (event) {
        event.preventDefault();// 阻止元素发生默认的行为
        $.ajax({
            url: base + "/stu/login",
            type: "POST",
            data: $(this).serialize(),
            success: function (data) {
                if (data == 1) {
                    // 说明登录成功,则跳转页面
                    window.location.href = base + "/permission/stuInfo/index";
                }else if (data == 0) {
					// 说明登录失败,显示提示
					$("#loginHint").html("<b>用户名或者密码有误!</b>");
				}else if (data == 2) {
					// 说明验证码错误,显示提示
					$("#loginHint").html("<b>验证码输入有误!</b>");
				}
            }
        });
    });
});

// 删除商品
function deleteStudent(stuno) {
	var r = confirm("确定要删除吗?");
	if (r) {
		// JS页面跳转
		window.location.href = base + "/permission/stuInfo/delete?stuno=" + stuno;
	}
}

// 安全退出
function logout() {
	var r = confirm("确定要退出吗?");
	if (r) {
		window.location.href = base + "/stu/logout";
	}
}

// 跳转修改页面
function editStudent(stuno) {
	window.location.href = base + "/permission/stuInfo/preEdit?stuno=" + stuno;
}

function addStudent() {
	window.location.href = base + "/permission/stuInfo/preAdd";
}

// 跳转上传页面
function checkInfo(stuno) {
	window.location.href = base + "/permission/stuInfo/checkInfo?stuno=" + stuno;
}

//分页查询
function go(pageNow){
	//window.location.href= base + "/permission/stuInfo/list?pageNow=" + pageNow;
	 $("#datas").load(base + "/permission/stuInfo/list?pageNow=" + pageNow + "&searchName=" + $("#searchName").val());
	//$("#datas").load(base + "/permission/stuInfo/list?pageNow=" + pageNow);
}

function changeCode(){
	$("#code").attr("src",base + "/code#" + new Date().getTime());
}
